#define _CRT_SECURE_NO_WARNINGS 1

#include <stdio.h>
#include <stdlib.h>

int* productExceptSelf(int* nums, int numsSize, int* returnSize) {
    int leftsum[10];
    int rightsum[10];
    int i = 0;
    leftsum[0] = 1;
    for (i = 1; i < numsSize; i++)
    {
        leftsum[i] = leftsum[i - 1] * nums[i - 1];
    }
    rightsum[numsSize - 1] = 1;
    for (i = numsSize - 2; i >= 0; i--)
    {
        rightsum[i] = rightsum[i + 1] * nums[i + 1];
    }
    *returnSize = numsSize;
    int* returnnums = (int*)malloc(sizeof(int) * numsSize);
    for (int i = 0; i < numsSize; i++)
    {
        returnnums[i] = leftsum[i] * rightsum[i];
    }
    return returnnums;
}

int main()
{
    int arr[] = { 1,2,3,4};
    int n = 0;
    int sz = sizeof(arr) / sizeof(arr[0]);
    int* print = productExceptSelf(arr, sz, &n);
    int i = 0;
    for (i = 0; i < n; i++)
    {
        printf("%d ", print[i]);
    }
    return 0;
}